package threadManger;

import sqlInject.Payload;

import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by td on 16/7/4.
 */
public class ThreadManager {
    public static ExecutorService es = null;

    public static synchronized ExecutorService createExcutorService() {
        if (getState() != -1) {
            es = Executors.newCachedThreadPool();
        }
        return es;
    }


    public static int getState() {
        if (es == null) {
            return 0;
        }
        if (es.isShutdown()) {
            return 1;
        }
        if (es.isTerminated()) {
            return 2;
        }
        return -1;

    }

    public static void shutdown() {
        if (es != null) {
            es.shutdown();
            es = null;
        }
    }

    public static void shutdownNow() {
        if (es != null) {
            es.shutdownNow();
            es = null;
        }
    }

    public static void main(String[] args) {
       List<HashMap<String,String>> payloads =  Payload.OrdinaryInjectionPayload.payloads;
        Iterator iterator = payloads.iterator();
        while (iterator.hasNext()){
            HashMap<String,String> hashMap = (HashMap<String, String>) iterator.next();
            Set<Map.Entry<String, String>> entries = hashMap.entrySet();
            for (Map.Entry<String,String> entry:entries){
                System.out.println(entry.getKey());
            }
        }
    }


}





